package com.example.myapplication.recyclerview;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.ListView;

import com.example.myapplication.R;
import com.example.myapplication.listview.Bean;
import com.example.myapplication.listview.MyAdapter;

import java.util.ArrayList;
import java.util.List;

public class RecyclerviewLayoutActivity extends AppCompatActivity {
    private List<Bean> date = new ArrayList<>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recyclerview_layout);

        for(int i=0;i<10000;i++){
            if(i%4==0){
                Bean bean = new Bean();
                bean.setName("Item::::::::"+i);
                date.add(bean);
            }
        }
        RecyclerView recyclerView = findViewById(R.id.rv);

//        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
//        GridLayoutManager gridLayoutManager = new GridLayoutManager(this,3);
        StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(3,LinearLayout.VERTICAL);


        recyclerView.setLayoutManager(staggeredGridLayoutManager);
        RecyclerviewAdapter recyclerviewAdapter = new RecyclerviewAdapter(date,this);
        recyclerView.setAdapter(recyclerviewAdapter);
        recyclerviewAdapter.setOnRecyclerItemClickListener(new RecyclerviewAdapter.OnRecyclerItemClickListener() {
            @Override
            public void onRecyclerItemClick(int position) {
                Log.e("RecyclerItem", "onRecyclerItemClick: "+position );
            }
        });

    }
}